<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>袁衣一中国</title>
<load type="css" href='__PUBLIC__/Css/home.css' />
<load href="__PUBLIC__/Js/jquery-1.4.min.js" />
<load href="__PUBLIC__/Js/Base.js" />
<load href="__PUBLIC__/Js/prototype.js" />
<load href="__PUBLIC__/Js/mootools.js" />
<load href="__PUBLIC__/Js/Ajax/ThinkAjax.js" />
<script type="text/javascript">
var seriesStr = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
function editSeries(index){
	jQuery('#'+index).attr('innerHTML','');
	var input = '<input id="'+index+'_input" onblur="javascript:updateSeries(\''+index+'\')" type="text"/>';
	var i = jQuery('#edit').append(input);
}
function updateSeries(index){
	var value = jQuery('#'+index+'_input').attr('value');
	if(jQuery.trim(value)==''){
		alert('请输入商品系列!');
		jQuery('#'+index+'_input').focus();
		return;
	}
	jQuery('#'+index).attr('innerHTML',value);
	jQuery('#'+index+'_input').remove();
}
jQuery(document).ready(function(){
	var speed = 500;
	for(i=0;i<seriesStr.length;i++){
		if(Number(jQuery('#store_'+seriesStr[i]+'_lnum').attr('value'))!=0){
			jQuery('#store_'+seriesStr[i]).slideDown(Number(jQuery('#store_'+seriesStr[i]+'_lnum').attr('value'))*speed);
		}
	}
	
	for(i=0;i<seriesStr.length;i++){
		jQuery("#createShelves_"+seriesStr[i]).click(function(event){
			event = event? event: window.event;
			event = event? event:eventTag;
			var obj = event.srcElement ? event.srcElement:event.target; 
			event.stopPropagation();
			var offset = jQuery(obj).offset();
			jQuery('#indexShelves').attr('value',jQuery(this).attr('id').substr(jQuery(this).attr('id').length-1,1));
			jQuery('#shelvesPop').css({top:offset.top + jQuery(obj).height() + "px",left:offset.left});
			jQuery('#shelvesPop').slideDown(speed);
		})
		jQuery("#series_"+seriesStr[i]).click(function(event){
			event = event? event: window.event
					var obj = event.srcElement ? event.srcElement:event.target; 
			event.stopPropagation();
			var value = jQuery.trim(jQuery('#series_A').attr('innerHTML'));
			jQuery('#txtSeries').attr('value',value);
			jQuery('#indexSeries').attr('value',value);
			var offset = jQuery(obj).offset();
			jQuery('#indexSeries').attr('value',jQuery(this).attr('id'));
			jQuery('#seriesPop').css({top:offset.top + jQuery(obj).height() + "px",left:offset.left});
			jQuery('#seriesPop').slideDown(speed);
		 })
	}
	jQuery("#test").click(function(){
		jQuery('#store').slideDown(speed);
		jQuery('#store').slideUp(speed);
	})
	
})
    
function cancelPop(div){
	var speed = 500;
	jQuery('#'+div).slideUp(speed);
	jQuery('#txtSeries').attr('value');
}


function updateSeries(){
	var value = jQuery('#txtSeries').attr('value');
	var series = jQuery('#indexSeries').attr('value');
	if(jQuery.trim(value)==''){
		alert('请输入商品系列!');
		jQuery('#txtSeries').focus();
		return;
	}
	ThinkAjax.send('__URL__/updateSeries','ajax=1&value='+value+'&series='+series,complete,'');
}
function complete(data,status,info){
	var speed = 500;
	if (status==1)
	{
		var seriescount = Number(jQuery('#seriescount').attr('innerHTML'));
		jQuery('#commoditycount').attr('innerHTML',seriescount+1);
		jQuery('#txtSeries').attr('value','');
		jQuery('#indexSeries').attr('value','');
		jQuery('#series_A').attr('innerHTML',data.value);
		jQuery('#seriesPop').slideUp(speed);
	}else{
		alert('更新商品系列失败！');
	}
}
function createShelves(){
	var speed = 500;
	var value = jQuery('#txtShelves').attr('value');
	var Shelves = jQuery('#indexShelves').attr('value');
	if((/^(\+|-)?\d+jQuery/.test( value )) || value < 0){
	    alert("货架数必须是正整数！"); 
	    jQuery('#txtShelves').focus();
	    return ;  
	}

	ThinkAjax.send('__URL__/addCommodity','ajax=1&count='+value+'&series='+Shelves+'&level=1',completeCreate,'');

}

function completeCreate(data,status,info){
	var speed = 500;
	var value = Number(data.count);
	var Shelves = jQuery('#indexShelves').attr('value');
	var snum  = Number(jQuery('#store_'+Shelves+'_snum').attr('value'));  //最后一行商品个数
	var lnum  = Number(jQuery('#store_'+Shelves+'_lnum').attr('value'));  //最大行索引
	var lacknum = snum==0?0:(5-snum);  //最后一行剩余空位
	var sunum = value-lacknum;//去除最后一样剩余的空位	
	
	if (status==0){
		alert(info);
		return;
	}
	
	if(snum!=0){
		strRemnant = '';
		for(i=0;i<(5-snum);i++){
			strRemnant += createTemplate(data.mcd_id[i]);
		}
		jQuery('#shelves_'+lnum).append(strRemnant);
	}
	var result = parseInt(sunum/5);  //新建整行数
	var remnant = sunum%5;			//最后一行个数
	var lineCount = result;
	if(remnant!=0){
		lineCount += 1;
	}
	for(i=lnum+1;i<=lnum+lineCount;i++){
		if(i%2==0){
			str = '<div id="shelves_'+i+'" style="width:100%;height:285px;background:#dfdfdd;">';
		}else{
			str = '<div id="shelves_'+i+'" style="width:100%;height:285px;">';
		}
		str += '</div>';
		jQuery('#store_'+Shelves).append(str);
	}
	var tempLineCount = remnant==0?lnum+lineCount+1:lnum+lineCount;
	for(i=lnum+1,t=0;i<tempLineCount;i++,t++){
		var str = "";
		for(k=0,j=t*5+lacknum;(j<data.mcd_id.length)&&k<5;k++,j++){
			str += createTemplate(data.mcd_id[j]);
		}
		jQuery('#shelves_'+i).append(str);
	}

	if(remnant!=0){
		strRemnant = '';
		for(i=result*5+lacknum;i<value;i++){
			strRemnant += createTemplate(data.mcd_id[i]);
		}
		jQuery('#shelves_'+(lnum+lineCount)).append(strRemnant);
	}
	if(snum==0&&lnum==0&&value!=0){
		var seriescount = Number(jQuery('#seriescount').attr('innerHTML'));
		jQuery('#commoditycount').attr('innerHTML',seriescount+1);
	}
	var commoditycount_s = Number(jQuery('#commoditycount_'+Shelves).attr('innerHTML'));
	var commoditycount = Number(jQuery('#commoditycount').attr('innerHTML'));
	jQuery('#commoditycount').attr('innerHTML',commoditycount+value);
	jQuery('#commoditycount_'+Shelves).attr('innerHTML',commoditycount_s+value);
	alert(info);
	jQuery('#store_'+Shelves+'_lnum').attr('value',lnum+lineCount);
	jQuery('#store_'+Shelves+'_snum').attr('value',remnant);
	jQuery('#store_'+Shelves).slideDown(speed);
	jQuery('#shelvesPop').slideUp(speed);
}

function createTemplate(id){
	strTemplate = '<div id="'+id+'" style="margin:20px 4%; float:left;">';
	strTemplate += '    <div style="width:150px;height:150px; border:1px solid #999"><span style="height:150px;line-height:150px;width:150px;display:block;text-align:center;">点击进入货品上架</span></div>';
	strTemplate += '    <div style="width:150px;height:80px;">';
	strTemplate += '        <ul style="width:150px;padding:0; font-size:12px; position:relative">';
	strTemplate += '            <li>货号：</li>';
	strTemplate += '            <li>名称：</li>';
	strTemplate += '            <li>价格：</li>';
	strTemplate += '            <li>件数：</li>';
	strTemplate += '            <div style=" position:absolute; right:0;top:0;"><a href="javascript:deleteStore(\''+id+'\')">删除</a></div>';
	strTemplate += '        </ul>';
	strTemplate += '    </div>';
	strTemplate += '</div>'; 
	return strTemplate;
}

function deleteStore(id){
	ThinkAjax.send('__URL__/deleteCommodity','ajax=1&id='+id,completeDelete,'');	
}
function completeDelete(data,status,info){
	if (status==0){
		alert(info);
		return;
	}
	jQuery("#"+data).remove();
	var Shelves = data.substr(-7,1);
	var commoditycount_s = Number(jQuery('#commoditycount_'+Shelves).attr('innerHTML'));
	var commoditycount = Number(jQuery('#commoditycount').attr('innerHTML'));
	jQuery('#commoditycount_'+Shelves).attr('innerHTML',commoditycount_s-1);
	jQuery('#commoditycount').attr('innerHTML',commoditycount-1);
	
}

function showOrHideSeries(sid,type,shelves){
	ThinkAjax.send('__URL__/showOrHideSeries','ajax=1&series_sid='+sid+'&type='+type+'&shelves='+shelves,completeShowOrHide,'');
}
function completeShowOrHide(data,status,info){
	if(status==0){
		alert(info);
		return;
	}
	var str = data=='1'?'<a href="javascript:showOrHideSeries(\'{$series.series_sid}\',\'0\',\'A\')">显示</a>':'<a href="javascript:showOrHideSeries(\'{$series.series_sid}\',\'1\',\'A\')">隐藏</a>';
	jQuery('#showOrHide').attr('innerHTML',str);
	
}
</script>
</head>
<body>
    <div style="height:100px">
        <div class="header_left">
        	<div><span style="font-size:30px;font-weight:200;">袁&nbsp;衣&nbsp;一&nbsp;中&nbsp;国</span><span>门&nbsp;店</span><span>点&nbsp;商</span><span>服&nbsp;务</span></div>
        	<div><input id="kw" type="text" name="searchForm"/><input type="submit" style="height:30px;" value="查&nbsp;找" /></div>
        </div>
        <div class="header_middle">
        	<div><a href="">点额充值</a></div>
            <div><span>剩余额数：{$vo.suser_pointcard}</span></div>
        </div>
        <div class="header_right">
        	<div style="margin-bottom:5px;"><span>地址：{$vo.store_address}</span></div>
            <div><span>电话:{$vo.suser_tel}</span><span style="margin-left:20px;">{$vo.suser_phone}</span></div>
        </div>  
    </div>
    <div id="storeInfo">
        <ul>
            <li style="margin-left:15px;">用户ID:{$vo.suser_id}</li>
            <li>经营方式:        			
            	<switch name="vo.store_type">
                    <case value="1">门店商</case>
                    <case value="2">批货商</case>
                    <case value="3">服务商</case>
     	         </switch></li>
            <li>经营类别:{$vo.store_category}</li>
            <li>QQ:{$vo.suser_qq}</li>
            <li style="margin-right:0px;">资料修改</li>
        </ul>
    </div>
    <div style="width:100%;">
    	 <div class="xltitle"><span style="margin-left:20px;">{$vo.store_name}</span><div style="float:right;margin-right:20px;"><span><input type="checkbox" id="s"/><label for="s">展开全选系列</label></span><span style="margin:0 10px;"><input type="checkbox" id="a" /><label for="a"><span id='test'>展开所选系列</span></label></span><span style="margin:0 10px;">货架总数：<span id="seriescount">{$seriescount}</span></span><span style="margin:0 0 0 10px;;">商品总数: <span id="commoditycount">{$commoditycount}</span></span></div></div>
        <div class="xllist">
        	<span style="margin-left:20px;">
        		<span id="series_A">                   
        			<switch name="series.series_A">
                        <case value="">商品系列A</case>
                        <default/>{$series.series_A}
      	            </switch>
        		</span>
        	</span>
        <div style="float:right;margin-right:20px;">
        	<span id="createShelves_A" style="margin:0 10px;color:blue;">新建货架</span>
        	<span id="showOrHide" style="margin:0 10px;">
        		<switch name="series.series_A_show">
                    <case value="0"><a href="javascript:showOrHideSeries('{$series.series_sid}','1','A')">隐藏</a></case>
                    <case value="1"><a href="javascript:showOrHideSeries('{$series.series_sid}','0','A')">显示</a></case>
     	         </switch>
        	</span>
        	<span style="margin:0 0 0 10px;">商品总数: <span id="commoditycount_A">{$commoditycount_A}</span></span>
        </div>
    </div>
    <div id="store_A" style="display:none;width:100%">
    	<input type="hidden" id ="store_A_snum" value="{$surpluscount_A}"/>
    	<input type="hidden" id ="store_A_lnum" value="{$linecount_A}"/>
    	<volist name="series_A" id="vo" mod="5">
    		<eq name="mod" value="1"><div id="shelves_{$key/5|floor}" style="width:100%;height:285px; <?php if((floor($key/5)%2)!==0) {echo 'background:#dfdfdd;';} ?>"></eq>
				<div id="{$vo.mcd_id}" style="margin:20px 4%; float:left;">
				    <div style="width:150px;height:150px; border:1px solid #999"><span style="height:150px;line-height:150px;width:150px;display:block;text-align:center;">点击进入货品上架</span></div>
				    <div style="width:150px;height:80px;">
				        <ul style="width:150px;padding:0; font-size:12px; position:relative">
				            <li>货号：{$vo.mcd_itemno}</li>
				            <li>名称：{$vo.mcd_title}</li>
				            <li>价格：{$vo.mcd_price}</li>
				            <li>数量：{$vo.mcd_num}</li>
				            <div style=" position:absolute; right:0;top:0;"><a href="javascript:deleteStore('{$vo.mcd_id}')">删除</a></div>
				        </ul>
				    </div>
				</div> 
    		<eq name="mod" value="0"></div></eq>
    	</volist>
    	</div>
    </div>

        <div class="xllist"><span style="margin-left:20px;">A 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">B 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">C 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">D 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">E 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">F 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">G 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">H 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">I 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">J 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">K 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">L 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">M 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">N 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">O 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">P 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">Q 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">R 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">S 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">T 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">U 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">V 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">W 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">X 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">Y 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div class="xllist"><span style="margin-left:20px;">Z 商品系列......</span><span style="float:right;margin-right:20px;">商品总数: 000000</span></div>
        <div style="height:20px;"><span style="margin-left:20px;"></div>
        <div class="xltitle" style=" text-align:center"><span style="margin:0 auto;">许可证编号：陕ICP备10200507号-1&nbsp;&nbsp;&nbsp;&nbsp;袁衣一中国&nbsp;&nbsp;&nbsp;&nbsp;版权所有</span></div>
    </div>
    <div id="shelvesPop" style="width:200px; height:50px; border:1px solid #666; background-color:#CCC; position:absolute; padding:10px 20px; display:none;">
		<div><span style="font-size:12px; float:left;height:25px;line-height:25px;">货架数量:</span><input id="txtShelves" type="text" size="15" /><input type="hidden" id="indexShelves" value=""/></div>
		<div style="text-align:center;"><input type="button" value="确认" onclick="javascript:createShelves()" /><input type="button" value="取消" onclick="javascript:cancelPop('shelvesPop')" /></div>
	</div>
    <div id="seriesPop" style="width:200px; height:50px; border:1px solid #666; background-color:#CCC; position:absolute; padding:10px 20px; display:none;">
		<div><span style="font-size:12px; float:left;height:25px;line-height:25px;">商品系列:</span><input id="txtSeries" type="text" size="15" /><input type="hidden" id="indexSeries" value=""/></div>
		<div style="text-align:center;"><input type="button" value="确认" onclick="javascript:updateSeries();" /><input type="button" value="取消" onclick="javascript:cancelPop('seriesPop')" /></div>
	</div>
</body>
</html>